﻿using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;

namespace DinheiroSobControle.Dominio
{
    public partial class DominioDataContext : IRepositorio
    {

        private static DominioDataContext _instancia;

        public static DominioDataContext Instancia
        {
            get
            {
                _instancia = _instancia ?? new DominioDataContext("");
                return _instancia;
            }
            set
            {
                _instancia = value;
            }
        }

        #region IRepositorio Members

        public IQueryable<MovimentacaoFinanceira> MovimentacaoFinanceiraDataSource
        {
            get { return GetQueryable<MovimentacaoFinanceira>(); }
        }

        public virtual IQueryable<TEntity> GetQueryable<TEntity>() where TEntity : class
        {
            return GetTable<TEntity>();
        }

        public virtual ITable GetEditable<TEntity>() where TEntity : class
        {
            return GetTable<TEntity>();
        }

        public void Insert<TEntity>(TEntity instance) where TEntity : class
        {
            GetEditable<TEntity>().InsertOnSubmit(instance);
        }


        public void InsertAll<TEntity>(IEnumerable<TEntity> instances) where TEntity : class
        {
            GetEditable<TEntity>().InsertAllOnSubmit(instances);
        }

        public void Delete<TEntity>(TEntity instance) where TEntity : class
        {
            GetEditable<TEntity>().DeleteOnSubmit(instance);
        }


        public void DeleteAll<TEntity>(IEnumerable<TEntity> instances) where TEntity : class
        {
            GetEditable<TEntity>().DeleteAllOnSubmit(instances);
        }

        #endregion
    }
}